package com.ldn.basic.enums;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 李大牛家的牛 (scafel@163.com)
 * @createDate 2024/9/29 - 13:56
 * @description ...
 **/
@Schema(description = "oss类型枚举")
@Getter
public enum OssTypeEnums {

    // 七牛云
    QINIU("QINIU", "七牛云"),
    // 阿里云
    ALIYUN("ALIYUN", "阿里云"),
    // 腾讯云
    TENCENT("TENCENT", "腾讯云"),
    // 未知
    UNKNOWN("UNKNOWN", "未知");

    ;


    private static final Map<String, OssTypeEnums> codeToEnumMap = new HashMap<>();

    static {
        for (OssTypeEnums type : OssTypeEnums.values()) {
            codeToEnumMap.put(type.getCode(), type);
        }
    }

    private final String code;
    /**
     * 自定义描述
     **/
    private final String message;

    OssTypeEnums(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public static OssTypeEnums getType(String code) {
        OssTypeEnums type = codeToEnumMap.get(code.toUpperCase());
        if (type == null) {
            return OssTypeEnums.UNKNOWN;
        }
        return type;
    }


}
